Here, you'll learn about the benefits
of using cascading style sheets or CSS, module styling over
an external style sheet. CSS external stylesheet class names and animation names,
are scoped globally by default. This can lead to conflict,
especially in large stylesheets, which means one style
can override another. CSS modules solve this problem,
by creating a separate file for each component and loading the file
when components get loaded. This helps in easy parsing of CSS style, composition helps in sharing
styles among all states. The composes keyword is conceptually
similar to extends, but works differently. Specificity issues disappear
with CSS modules or local scope. For example, you have a class such as dot Big in one
module where it changes the font size. In another, you use the same class
dot big that increases padding and font size in a different amount. It doesn't matter as they won't conflict, because the styles
are scoped deliberately. Even if a module imports
both style sheets, then it has a custom name that our build
process makes specifically for that class. In other words, specificity issues
disappear with CSS modules. Here, you'll learn about some
CSS module facts in react, a CSS module is not an official spec or
an implementation in the browser. It is a process in a build step
with the help of web pack or browserify the changes class names and
selectors to be scope. It is not officially supported by react,
it is supported by create react app that internally implements
it as part of react-scripts. React-scripts internally
use the package called CSS-loader to support CSS
using the module in react. Here, you'll learn about
styling components using CSS files as modules in react. Create a new file called
ModuleStyling.module.CSS, and insert some CSS code in
it as shown in the left code. Now, import the style sheet in your
application as shown in the right code. Access the style class name
using styles class name to add styles to your component
using the module style file. The CSS module creates a unique
class name for each style object. This unique class name has file name
underscore class name underscore unique code format, which resolves
the conflicts between class names.